package com.Adapters;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.Adapters.Items.ItemProfile;
import com.Animations.AnimUtil;
import com.TextFormat.UtilFonts;
import com.shareup.R;


public class ProfileAdapter extends ArrayAdapter<ItemProfile> {

    public static final int ITEM = 0;

    public static final int ITEM_LOCATION = 1;

    public ProfileAdapter(Context context) {

        super(context, 0);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            int res = R.layout.item_menu_row;
            convertView = LayoutInflater.from(getContext()).inflate(res, null);
        }
        //
        RelativeLayout container = (RelativeLayout) convertView.findViewById(R.id.container);
        container.setVisibility(View.INVISIBLE);
        ImageView icon = (ImageView) convertView.findViewById(R.id.row_icon);
        icon.setImageResource(getItem(position).iconRes);
        TextView title = (TextView) convertView.findViewById(R.id.row_title);
        UtilFonts.setTextRegularFont(title);
        title.setText(getItem(position).tag);
        title.setTextColor(convertView.getResources().getColor(R.color.background));

        if (getItem(position).isCoordinate) {
            convertView.setTag(ITEM_LOCATION);
        }
        else {
            convertView.setTag(getItem(position).id);
        }

        AnimUtil.animateFadeIn(container);
        return convertView;
    }

}
